package cn.itcast.ssh.web.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

import cn.itcast.ssh.entity.User;
import cn.itcast.ssh.service.UserService;

@Controller
@Scope("prototype")
@ParentPackage("struts-default")
@Namespace("/")
public class UserAction {
	@Autowired
	private UserService userService;

	@Action(value = "userAction_findAll", results = { @Result(name = "list", location = "/list.jsp") })
	public String findAll() {
		List<User> list = userService.findAll();
		ActionContext.getContext().getValueStack().push(list);
		return "list";
	}
}
